var vm_customlist = new Vue({
    el: "#customlist",
    data: {
        deptid: $("#deptid").val(),		// 单位ID
        parentid : $("#parentid").val(),

        yuelist: [],// 退款list

        pageindex: 1,		// 查询分页初始化页
        pagesize: 10,		// 查询分页初始化页面大小
        pageCount: 0,		// 总页数
        recordCount: 0,	// 总记录数
        targetpage: '', 	// 目标页

    },
    created: function () {
        var _this = this;

        _this.bindYueList();
    },
    watch: {
        //监控分页情况，刷新列表
        pageindex: function () {
            this.bindYueList();
        },
        pagesize: function () {
            //
            this.bindYueList();
        },
    },
    methods: {

        // 根据单位ID查询专家变动申请信息
        bindYueList: function () {
            var _this = this;

            var parentid = "";

            if(_this.parentid!=""){
                parentid = _this.parentid;
            }else{
                parentid = _this.deptid;
            }

            $.post('/system/yue/find_by_parentid', {
                parentid: parentid,
                // pageindex: _this.pageindex,
                // pagesize: _this.pagesize,
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == "1") {
                        var data = ppData.resultContent;
                        _this.yuelist = data;
                        /*var pageInfo = data.PageInfo;
                        _this.pageindex = pageInfo.pageIndex;
                        _this.pageCount = pageInfo.pageCount;
                        _this.recordCount = pageInfo.recordCount;
                        _this.targetpage = '';*/
                    } else {
                        layer.alert(ppData.message)
                    }
                }
            }, "json");
        },

        //
        toCustomYueList : function(yueitem){
            $.modal.openTab("单位余额详情",'system/yue/customlist?parentid='+yueitem.deptid,false);
        },

        //首页
        firstPage: function () {
            this.pageindex = 1;
        },
        //尾页
        lastPage: function () {
            this.pageindex = this.pageCount;
        },
        //上一页
        prePage: function () {
            var prePage = ((this.pageindex - 1) <= 0) ? 1 : (this.pageindex - 1);
            this.pageindex = prePage;
        },
        //下一页
        nextPage: function () {
            var nextPage = ((this.pageindex + 1) >= this.pageCount) ? this.pageCount : (this.pageindex + 1);
            this.pageindex = nextPage;
        },
        //跳到目标页
        targetPage: function () {
            if (this.targetpage != '' && this.targetpage <= this.pageCount && this.targetpage > 0) {
                this.pageindex = this.targetpage;
                this.targetpage = '';
            }
        },

    },
})